Public Class frmLeague
    Private Sub btnNewLeague_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewLeague.Click
        'New League
        Dim myLeague As coachingAppObjects.rw_leagueRoot
        myLeague = coachingAppObjects.rw_leagueRoot.NewleagueRoot(0)
        myLeague.LeagueName = Me.txtNewLeague.Text
        myLeague.Save()
        loadLeagues()
        txtNewLeague.Text = ""
    End Sub

    Private Sub frmLeague_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loadLeagues()
    End Sub

    Private Sub cboLeagues_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboLeagues.SelectedIndexChanged
        'Console.WriteLine(CType(cboLeagues.SelectedItem, coachingAppObjects.ro_leagueChild).LeagueId)
        Me.txtExistingLeagueName.Text = cboLeagues.SelectedValue.ToString
    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim myLeague As coachingAppObjects.rw_leagueRoot
        myLeague = coachingAppObjects.rw_leagueRoot.GetleagueRoot(CType(cboLeagues.SelectedItem, coachingAppObjects.ro_leagueChild).LeagueId)
        myLeague.LeagueName = txtExistingLeagueName.Text
        myLeague.Save()
        loadLeagues()
    End Sub

    Private Sub loadLeagues()
        'Get LeagueList

        Dim myLeagueList As coachingAppObjects.ro_leagueRootList
        myLeagueList = coachingAppObjects.ro_leagueRootList.GetLeagueRootList
        Me.cboLeagues.DataSource = myLeagueList
    End Sub
End Class
